package com.github.shiqiyue.app.modules.app.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.shiqiyue.app.api.sapi.req.notice.NoticePageReq;
import com.github.shiqiyue.app.modules.app.entity.Notice;
import com.github.shiqiyue.app.modules.app.enums.NoticeStatusEnum;
import com.github.shiqiyue.app.modules.app.mapper.NoticeMapper;
import com.github.shiqiyue.app.modules.app.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wenyao.wu
 * @since 2020-09-21
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {

    @Override
    public IPage<Notice> page(NoticePageReq noticePageReq) {
        return baseMapper.page(new Page<Notice>(noticePageReq.getCurrent(), noticePageReq.getSize()), noticePageReq);
    }

    @Override
    public void addNotice(String title, String content) {
        Notice notice = new Notice();
        notice.setTitle(title);
        notice.setContent(content);
        notice.setStatus(NoticeStatusEnum.ON.getValue());
        this.save(notice);

    }
}
